﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VISS.API.Users;

namespace VISS.Web.BackEnd.Modules.User {

    public partial class AccountBoxControl : System.Web.UI.UserControl {

        public UserEnt UserItem { get; set; }

        protected string UserStatus { get; set; }

        protected void Page_Load(object sender, EventArgs e) {
            UserStatus = string.Empty;
            bool canDoOtherUserStatus = true;
            string activeUserStatus = "<input type=\"checkbox\" id=\"chkActive-"+UserItem.UserKey+"\" onclick=\"UserActive('" + UserItem.UserKey + "');\" {0} /><label for=\"chkActive-" + UserItem.UserKey + "\">Kích hoạt</label>";
            if ((UserItem.Status & EUserStatus.Actived) == EUserStatus.Actived) {
                UserStatus += string.Format(activeUserStatus, "checked=\"checked\" disabled");
            }
            else {
                UserStatus += string.Format(activeUserStatus, "");
                canDoOtherUserStatus = false;
            }
            UserStatus += ", ";

            string verifyUserStatus = "<input type=\"checkbox\" id=\"chkVerify-" + UserItem.UserKey + "\" onclick=\"UserVerify('" + UserItem.UserKey + "');\" {0} /><label for=\"chkVerify-" + UserItem.UserKey + "\">Duyệt</label>"; ;
            if ((UserItem.Status & EUserStatus.Verified) == EUserStatus.Verified) {
                UserStatus += string.Format(verifyUserStatus, "checked=\"checked\"");
            }
            else {
                if (!canDoOtherUserStatus) {
                    UserStatus += string.Format(verifyUserStatus, "disabled");
                }
                else {
                    UserStatus += string.Format(verifyUserStatus, "");
                }
            }
            UserStatus += ", ";

            string disableUserStatus = "<input type=\"checkbox\" id=\"chkDisable-" + UserItem.UserKey + "\" onclick=\"UserDisable('" + UserItem.UserKey + "');\" {0} /><label for=\"chkDisable-" + UserItem.UserKey + "\">Khóa</label>"; ;
            if ((UserItem.Status & EUserStatus.Disabled) == EUserStatus.Disabled) {
                UserStatus += string.Format(disableUserStatus, "checked=\"checked\"");
            }
            else {
                if (!canDoOtherUserStatus) {
                    UserStatus += string.Format(disableUserStatus, "disabled");
                }
                else {
                    UserStatus += string.Format(disableUserStatus, "");
                }
            }
        }
    }
}